<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;
use App\model\Base;
class Zan extends Base
{
    protected $guarded=[];
    public $disable_ips=["117.71.110.59","36.5.134.209"];
    //详情点击
    public  function isClick($id){
        $ip=get_ip();
        if ($ip){
            $ips=explode(".",$ip);
            if(count($ips)==4){
                $d=Blacklist::query()->whereraw("inet_aton(ip) between inet_aton('$ips[0].$ips[1].$ips[2].1') and inet_aton('$ips[0].$ips[1].$ips[2].255')")->first();

                if(!empty($d)){
                    abort(404);
                }
            }
        }
        $count=$this->where('type','=',0)
            ->where('ip','=',$ip)
            ->where('article_id','=',$id)
            ->count();
        if($count>0){
            return true;
        }else{
            $this->ip = $ip;
            $this->article_id=$id;
            $this->type=0;
            $this->save();
            return false;
        }
    }
}
